import { LoadHtml } from './loadHtml.js'
import { vuexStore } from './vuexStore.js'

LoadHtml.loadVue('../views/switchMapControl.vue', 'switchMapControlContainer');

function initSwitchMapControl(switchMap) {
    let vue = new Vue({
        el: '#switchMapControl',
        name: 'switchMapControl',
        created() {

        },
        data() {
            return {
                imgs: [{
                    src: './images/e-map.png',
                    type: 1,
                    alt: '电子地图'
                },
                {
                    src: './images/image-map.png',
                    type: 2,
                    alt: '卫星地图'
                }]
            };
        },
        methods: {
            imgClick(e) {
                let type = parseInt(e.target.attributes['value'].value);
                switchMap(type);
            },
            getImgClass(type) {
                let imgMargin = type === 1;

                if (vuexStore.state.mapTileType === type) {
                    return { imgCurrent: true, imgMargin: imgMargin }
                } else {
                    return { img: true, imgMargin: imgMargin }
                }
            }
        },
        computed: {

        }
    });
}

export { initSwitchMapControl }
